package com.bignerdranch.android.furnitureapplication.net;

import android.os.Build;
import android.webkit.WebSettings;

import com.bignerdranch.android.furnitureapplication.FurnitureApp;

public class ApiConstants {

	public static final String COMMON_UA_STR = getUserAgent();

	public static final String TEST_BASEURL = "http://10.0.2.2:8080";
	public static final String MY_SERVER_URL = "http://115.159.191.105/";

	private static String getUserAgent() {
		String userAgent = "";
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
			try {
				userAgent = WebSettings.getDefaultUserAgent(FurnitureApp.getInstance());
			} catch (Exception e) {
				userAgent = System.getProperty("http.agent");
			}
		} else {
			userAgent = System.getProperty("http.agent");
		}
		StringBuffer sb = new StringBuffer();
		for (int i = 0, length = userAgent.length(); i < length; i++) {
			char c = userAgent.charAt(i);
			if (c <= '\u001f' || c >= '\u007f') {
				sb.append(String.format("\\u%04x", (int) c));
			} else {
				sb.append(c);
			}
		}
		return sb.toString();
	}

}
